package cn.usain.controller;

import cn.usian.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;



@RestController
@RequestMapping("order")
public class OrderController {

    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("findPage")
    public String findPage(@RequestParam(defaultValue = "1") Integer pageIndex, String name){
        return restTemplate.getForObject("http://studentservice/student/findPage?pageIndex="+pageIndex+"&name="+name,String.class);
    }

    @RequestMapping("add")
    public String add(@RequestBody Student student){
        String forObject=restTemplate.postForObject("http://studentservice/student/add",student,String.class);
        return forObject;
    }

    @RequestMapping("del")
    public String del(Long id){
        return restTemplate.getForObject("http://studentservice/student/del?id="+ id,String.class);
    }
}
